home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.HeadD
- {
- var x;
- var y;
- var moveScript;
- var id;
- var clip;
- var colorR;
- var trans;
- var colorTrans;
- var f2;
- var dir;
- var axis;
- var xDest;
- var yDest;
- var ep;
- var oldDir;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 8;
- var speed = 8;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var life = 3;
- var nc = 0;
- var xA = 0;
- var yA = 0;
- var nudging = false;
- var hc = 0;
- var power = 15;
- var Name = "headD";
- function HeadD(px, py, pmoveScript, pid)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("headB","headD" + this.id + "Clip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.life *= _root.dif.life;
- this.speedVar();
- this.colorR = -255;
- this.trans = new flash.geom.Transform(this.clip);
- this.colorTrans = new flash.geom.ColorTransform(0,0,0,1,this.colorR,this.colorR,this.colorR,0);
- this.trans.colorTransform = this.colorTrans;
- this.parseMoveScript();
- _root.stats.created = _root.stats.created + 1;
- }
- function nudge(pxA, pyA, pscale)
- {
- this.nc = 0;
- this.nudging = true;
- var _loc2_ = pscale / 100;
- this.xA = pxA * _loc2_;
- this.yA = pyA * _loc2_;
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.9998,1.0002);
- }
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- this[this.axis + "MovT"] = 0;
- this.f2 = "wander";
- if(random(10) > 2)
- {
- this.dir = _root.getDir(this.x,this.y);
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- }
- else
- {
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function wander()
- {
- if(random(100) > 70 || (this.x > 950 || this.x < 50 || this.y < 50 || this.y > 550))
- {
- if(random(20) > 18)
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "wait";
- this.c = 0;
- this.ep = _root.randRange(30,120);
- this.ep *= 1 / _root.dif.speed;
- }
- else if(random(10) > 1)
- {
- this.dir = _root.getDir(this.x,this.y);
- this[this.axis + "MovT"] = 0;
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- }
- function wait()
- {
- this.c = this.c + 1;
- if(this.c >= this.ep)
- {
- this.f2 = "wander";
- if(random(10) > 2)
- {
- this.dir = _root.getDir(this.x,this.y);
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- }
- else
- {
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- }
- if(random(100) > 95)
- {
- var _loc3_ = ["L","R","F"];
- this.dir = _loc3_[random(_loc3_.length)];
- }
- }
- function attacking()
- {
- }
- function death()
- {
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 750;
- _root.powerUpB(this.x,this.y,80,"tripleTwistLaser",4);
- _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(75,100)]);
- var _loc3_ = 0;
- var _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"headB","",false,true]);
- _loc3_ = _loc3_ + 1;
- }
- _root.audio.playLevel4("headX" + (random(3) + 1),_root.randRange(15,25));
- _root.removeChar("headD" + this.id);
- this.f2 = "";
- }
- function death2()
- {
- _root.removeChar("headD" + this.id);
- this.f2 = "";
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- if(this.oldDir == undefined || this.dir == "F")
- {
- this.clip.body.eyes.gotoAndStop(this.dir);
- }
- else if(this.dir == "U" || this.dir == "D")
- {
- this.clip.body.eyes.gotoAndStop(this.oldDir);
- }
- else if(random(3) > 0)
- {
- if(this.dir == "R")
- {
- this.clip.body.eyes.gotoAndPlay("LtoR");
- }
- else
- {
- this.clip.body.eyes.gotoAndPlay("RtoL");
- }
- }
- else
- {
- this.clip.body.eyes.gotoAndPlay("spin" + this.dir);
- }
- }
- this.oldDir = this.dir;
- if(this.nudging)
- {
- this.xA *= 0.5;
- this.yA *= 0.5;
- this.nc = this.nc + 1;
- var _loc8_ = 255 - this.nc * 17;
- this.colorTrans.redOffset = _loc8_ / 2;
- this.trans.colorTransform = this.colorTrans;
- if(this.nc == 15)
- {
- this.xA = this.yA = 0;
- this.nudging = false;
- this.colorTrans.redOffset = this.colorR;
- this.trans.colorTransform = this.colorTrans;
- }
- }
- var _loc4_ = 0;
- var _loc7_ = _root.broShots.length;
- while(_loc4_ < _loc7_)
- {
- var _loc6_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc6_]))
- {
- var _loc3_ = _root.broShots[_loc4_];
- var _loc5_ = this.life;
- this.life -= _root[_loc3_].power;
- if(this.life < 1)
- {
- this.f2 = "death";
- }
- else
- {
- this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,10);
- _root.audio.playLevel4("headHit" + (random(4) + 1),_root.randRange(18,28));
- this[this.axis + "MovT"] = 0;
- this.axis = random(10) <= 4 ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(_loc5_);
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.f2 = "death";
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 0.3;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 0.3;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 0.3;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 0.3;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- if(random(100) > 98)
- {
- this.clip.body.eyes.clip.gotoAndPlay("blink");
- }
- this.x += this.xMov + this.xA;
- this.y += this.yMov + this.yA + 0.5 * Math.sin(this.hc += 0.1);
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-